package com.h3bpm.kumhosunny.crm.controller.contactfilemanager;/**
 * @Auther: Administrator
 * @Date: 2019/11/7 16:33
 * @Description:
 */

import OThinker.H3.Controller.ControllerBase;
import com.alibaba.fastjson.JSONObject;
import com.h3bpm.kumhosunny.common.utils.SqlUtil;
import data.DataTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName 联系人验证接口
 * @Description: 描述
 *
 * @author WJQ
 * @version V1.0
 * @Date
 */
@Controller
@RequestMapping({"/Portal/ContactFileManager"})
public class ContactFileManagerController extends ControllerBase {

    private static Logger log = LoggerFactory.getLogger(ContactFileManagerController.class);

    @Override
    public String getFunctionCode() {
        return null;
    }
    @RequestMapping("/testContactFileManager")
    @ResponseBody
    public JSONObject testContactFileManager(String customerName, String customerCode, String mobile) {
        log.info("联系人档案验证接口：========"+"customerName"+customerName+"===customerCode"+customerCode+"====mobile"+mobile);
        JSONObject result= new JSONObject();
        if(customerName==null && customerCode==null && mobile==null) {
            return null;
        }
        String sql = "select * from i_ContactFileManager where customerName='"
                +customerName+"' and customerCode='" + customerCode+"' and mobile='"
                +mobile+"'";
        DataTable table =null;
        try{
         table =  SqlUtil.doQuery(sql);
            if(table!=null && table.getEntityRows()!=null && table.getEntityRows().size()>0){
                result.put("data","联系人已存在！");
                result.put("status","200");
                return  result;
            }
            return null;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    @RequestMapping("/testContactProfile")
    @ResponseBody
    public JSONObject testContactProfile(String customerCode) {
        log.info("联系人档案验证客户档案是否存在接口：===========customerCode=" + customerCode);
        JSONObject result= new JSONObject();
        if( customerCode==null ) {
            return null;
        }
        String sql = "select * from i_customerprofile where "+
                " customerCode='" + customerCode+"'";
        DataTable table =null;
        try{
            table =  SqlUtil.doQuery(sql);
            if(table!=null && table.getEntityRows()!=null && table.getEntityRows().size()>0){
            }else {
                result.put("data","清先添加该客户的客户档案！");
                result.put("status","200");
                return  result;
            }
            return null;
        }catch (Exception e){
            e.printStackTrace();
        }
        return  null;

    }
}
